package gemini.castor.ui.client.page.widget.productpreview;

import com.google.gwt.event.shared.GwtEvent;

public class ProductPreviewEvent extends GwtEvent<ProductPreviewHandler> {

	private static Type<ProductPreviewHandler> TYPE;
	
	public static Type<ProductPreviewHandler> getType() {
		if (TYPE == null)
			TYPE = new Type<ProductPreviewHandler>();
		return TYPE;
	}
	
	public enum ForwardType {
		SELECT;
	}
	
	public ProductPreviewEvent(ForwardType forwardType) {
		super();
		this.setForwardType(forwardType);
	}
	
	private ForwardType forwardType;
	
	@Override
	protected void dispatch(ProductPreviewHandler handler) {
		if(forwardType.equals(ForwardType.SELECT)){
			handler.onSelected(this);
		}
	}
	
	@Override
	public Type<ProductPreviewHandler> getAssociatedType() {
		return getType();
	}

	public void setForwardType(ForwardType forwardType) {
		this.forwardType = forwardType;
	}

	public ForwardType getForwardType() {
		return forwardType;
	}
}
